cal.yr
. The function is intended for epidemiological
use, and the dates are converted to a calendar time scale that has 4
years of equal length between 1.1.1970 and 1.1.1974 etc. The printing of
cal.yr
objects in human readable form may therefore be as much
as 3 days wrong.cal.yr(x, format)
dmy.cal.yr( d, m, y )
mdy.cal.yr( m, d, y )
ymd.cal.yr( y, m, d )
weekdays.cal.yr( x, abbreviate=FALSE )
weeks( x )
weeks.cal.yr( x )
months.cal.yr( x, abbreviate=FALSE )
print.cal.yr( x, format="%d/%m/%Y", ... )
strptime
for
admissible values.cal.yr
returns a numerical vector of the same length as
x
. The associated print method, print.cal.yr
prints the
dates in human readable format. To see the dates as fractions of
years, use as.numeric(cy)
.
dmy.cal.yr
, mdy.cal.yr
and ymd.cal.yr
are
convenience functions for converting separate numerical variables
with date d
, month m
and year y
into dates of
class cal.yr
. These functions also accept a single character
variable as input, with two digits for day and month and four for year
and any delimiters.
weekdays.cal.yr
, weeks.cal.yr
and months.cal.yr
,
extract weekday, week number and month from calendar year
objects. weekdays
and months
return factors with 7 and
12 levels respectively, regardless of the actually occurring number of
levels. weeks
return numeric values in the range 1--52.DateTimeClasses
,
Date
birth <- c("14/07/1952", "01/04/1954", "10/06/1987")
( bt.yr <- cal.yr( birth, format="%d/%m/%Y" ) )
as.numeric( bt.yr )
weeks( bt.yr )
months( bt.yr )
( bt.y <- dmy.cal.yr( birth ) )
Run the code above in your browser using DataLab